﻿using System;
using System.IO;
using UnityEngine;

// Token: 0x020002EC RID: 748
public class SaveHeader
{
	// Token: 0x0600131A RID: 4890 RVA: 0x00089850 File Offset: 0x00087A50
	public SaveHeader()
	{
		this.Clear();
	}

	// Token: 0x0600131B RID: 4891 RVA: 0x00089860 File Offset: 0x00087A60
	public SaveHeader(SaveHeader copy)
	{
		this.version = copy.version;
		this.comment = copy.comment;
		this.time = copy.time;
	}

	// Token: 0x0600131C RID: 4892 RVA: 0x0008988C File Offset: 0x00087A8C
	public SaveHeader(int version)
	{
		this.version = version;
		this.comment = string.Empty;
		this.time = string.Empty;
	}

	// Token: 0x0600131D RID: 4893 RVA: 0x000898B4 File Offset: 0x00087AB4
	public void Clear()
	{
		this.version = -1;
		this.comment = string.Empty;
		this.time = string.Empty;
	}

	// Token: 0x0600131E RID: 4894 RVA: 0x000898D4 File Offset: 0x00087AD4
	public bool Load(BinaryReader reader)
	{
		int num = reader.ReadInt32();
		if (num > 5)
		{
			GlobalData.Debug_LogError("不明版本");
			return false;
		}
		this.version = reader.ReadInt32();
		this.comment = reader.ReadString();
		this.time = reader.ReadString();
		return true;
	}

	// Token: 0x0600131F RID: 4895 RVA: 0x00089920 File Offset: 0x00087B20
	public bool Load(string path)
	{
		FileStream fileStream = null;
		try
		{
			fileStream = File.OpenRead(path);
		}
		catch
		{
			return false;
		}
		if (fileStream == null)
		{
			return false;
		}
		BinaryReader reader = new BinaryReader(fileStream);
		bool result = this.Load(reader);
		fileStream.Close();
		return result;
	}

	// Token: 0x06001320 RID: 4896 RVA: 0x00089974 File Offset: 0x00087B74
	public bool Save(BinaryWriter writer)
	{
		this.time = SaveHeader.NowTimeToStr();
		writer.Write(5);
		writer.Write(this.version);
		writer.Write(this.comment);
		writer.Write(this.time);
		return true;
	}

	// Token: 0x06001321 RID: 4897 RVA: 0x000899B0 File Offset: 0x00087BB0
	public void SetNowTime()
	{
		this.time = SaveHeader.NowTimeToStr();
	}

	// Token: 0x06001322 RID: 4898 RVA: 0x000899C0 File Offset: 0x00087BC0
	public static string NowTimeToStr()
	{
		return string.Concat(new string[]
		{
			DateTime.Now.Year.ToString("0000"),
			"/",
			DateTime.Now.Month.ToString("00"),
			"/",
			DateTime.Now.Day.ToString("00"),
			" ",
			DateTime.Now.Hour.ToString("00"),
			":",
			DateTime.Now.Minute.ToString("00"),
			":",
			DateTime.Now.Second.ToString("00")
		});
	}

	// Token: 0x06001323 RID: 4899 RVA: 0x00089ABC File Offset: 0x00087CBC
	public static SaveHeader LoadSaveHeader(string path)
	{
		FileStream fileStream = null;
		try
		{
			fileStream = File.OpenRead(path);
		}
		catch
		{
			return null;
		}
		if (fileStream == null)
		{
			return null;
		}
		BinaryReader reader = new BinaryReader(fileStream);
		SaveHeader saveHeader = new SaveHeader();
		bool flag = saveHeader.Load(reader);
		fileStream.Close();
		if (flag)
		{
			return saveHeader;
		}
		return null;
	}

	// Token: 0x04001828 RID: 6184
	public int version;

	// Token: 0x04001829 RID: 6185
	public string comment;

	// Token: 0x0400182A RID: 6186
	public string time;

	// Token: 0x020002ED RID: 749
	public enum VERSION
	{
		// Token: 0x0400182C RID: 6188
		VERSION_0,
		// Token: 0x0400182D RID: 6189
		VERSION_1,
		// Token: 0x0400182E RID: 6190
		VERSION_2,
		// Token: 0x0400182F RID: 6191
		VERSION_3,
		// Token: 0x04001830 RID: 6192
		VERSION_4,
		// Token: 0x04001831 RID: 6193
		VERSION_5,
		// Token: 0x04001832 RID: 6194
		NEXTVERSION,
		// Token: 0x04001833 RID: 6195
		NEW_VERSION = 5
	}
}
